import goods.Way;
import goods.bread.bread;
import goods.bread.cake;
import goods.snack.baomihua;
import goods.snack.chocolate;
import goods.snack.weilong;
import goods.wine.fenjiu;
import goods.wine.juice;
import goods.wine.wz;
import goods.wine.xb;
import operation.purchase;
import operation.shoppingCar;

import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        ArrayList<Way> breadArrayList = new ArrayList<>();
        ArrayList<Way> snackArrayList = new ArrayList<>();
        ArrayList<Way> wineArrayList = new ArrayList<>();
        breadArrayList.add(new cake());
        breadArrayList.add(new bread());
        snackArrayList.add(new baomihua());
        snackArrayList.add(new chocolate());
        snackArrayList.add(new weilong());
        wineArrayList.add(new fenjiu());
        wineArrayList.add(new juice());
        wineArrayList.add(new wz());
        wineArrayList.add(new xb());
        shoppingCar car = new shoppingCar();
        System.out.println("欢迎来到购物平台");
        boolean flag = true;
        while (flag) {
            System.out.println("请选择需要的服务\n" + "1:查看商品类商品\n" + "2:添加商品到购物车\n" + "3:删除商品\n" +
                "4:查看购物车商品\n" + "5:结算");
            Scanner sc = new Scanner(System.in);
            int idx = sc.nextInt();
            switch (idx) {
                case 1:
                    System.out.println("请选择要查看的商品\n" + "1:酒水类\n" + "2:零食类\n" + "3:面包类");
                    int i = sc.nextInt();
                    if (i == 1) {
                        for (Way good : wineArrayList) {
                            System.out.println(good);
                        }
                    }
                    if (i == 2) {
                        for (Way good : snackArrayList) {
                            System.out.println(good);
                        }
                    }
                    if (i == 3) {
                        for (Way good : breadArrayList) {
                            System.out.println(good);
                        }
                    }
                    break;
                case 2:
                    System.out.println("根据下列选项选择要添加的商品与数目");
                    System.out.println("请先输入需要的数目");
                    int number = sc.nextInt();
                    int j = sc.nextInt();
                    switch (j) {
                        case 1:
                            purchase good = new purchase(new xb(), number);
                            car.add(good);
                            break;
                        case 2:
                            purchase good2 = new purchase(new wz(), number);
                            car.add(good2);
                            break;
                        case 3:
                            purchase good3 = new purchase(new juice(), number);
                            car.add(good3);
                            break;
                        case 4:
                            purchase good4 = new purchase(new fenjiu(), number);
                            car.add(good4);
                            break;
                        case 5:
                            purchase good5 = new purchase(new chocolate(), number);
                            car.add(good5);
                            break;
                        case 6:
                            purchase good6 = new purchase(new baomihua(), number);
                            car.add(good6);
                            break;
                        case 7:
                            purchase good7 = new purchase(new bread(), number);
                            car.add(good7);
                            break;
                        case 8:
                            purchase good8 = new purchase(new cake(), number);
                            car.add(good8);
                            break;
                        case 9:
                            purchase good9 = new purchase(new weilong(), number);
                            car.add(good9);
                            break;
                        default:
                            break;
                    }
                    break;
                case 3:
                    System.out.println("输入你要删除的商品名称");
                    String name = sc.next();
                    car.delete(name);
                case 4:
                    car.show();
                    break;
                case 5:
                    System.out.println("共计消费为" + car.check());
                    break;
                default:
                    flag = false;
            }
        }
    }
}